const {getHktkHttp}  =require("../../utils/top-htp")
Page({

    /**
     * 页面的初始数据
     */
    data: {
        musics:[],
        limit:20
    },
    onLoad:function(options){
        var limit = this.data.limit
        getHktkHttp(limit).then(res=>{
            //console.log(res);
            var musics = []
            var toplist = res.data.toplist

            toplist.forEach(item=>{
               console.log(item);
               var {program}=item;
                var name = program.mainSong.name
                var imgUrle = item.program.coverUrl
                var id = program.mainSong.id
               musics.push({
               name,
               imgUrle,
               id
               })  
            })
            //console.log(musics);
            this.setData({
             musics
            })

        })
    },
    onReachBottom(){
        console.log("bottom");
        var limit=this.data.limit
        var musicss=this.data.musics
        limit+=20;
        getHktkHttp(limit).then(res=>{
           musicss = []
            var toplist = res.data.toplist

            toplist.forEach(item=>{
               console.log(item);
               var {program}=item;
                var name = program.mainSong.name
                var imgUrle = item.program.coverUrl
                var id = program.mainSong.id
               musicss.push({
               name,
               imgUrle,
               id
               })  
                //    musics.push(...res.data.toplist)
            })
    

          this.setData({
            musics:[...musicss],
            limit
          })
        })
      }

  
})